<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>栏目管理</title>

    <!-- Bootstrap -->
    <link href="/Public/Admin/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- <link rel="stylesheet" type="text/css" href="css/index.css"> -->
    <link rel="stylesheet" type="text/css" href="/Public/Admin/css/rightmain.css">
  </head>
  <body>
      <div class="iframecontent">
        <div class="pos">
         <i class="icoh"></i>
          <span>栏目列表</span>
        </div>
        <div class="operate">
          <div class="pull-left">
            <input type="button" name="" value="添加栏目" class="btn  btn-success">
            <input type="button" name="" value="批量删除" class="btn btn-danger">
          </div>
          <!-- operate标题结束 -->
          <div class="list">
            <div class="tablewrap">
              <table class="table" width="100%" id="datalist">
                <thead>
                  <tr>
                    <th><input type="checkbox" name="" id="all"></th>
                    <th>编号</th>
                    <th>名称</th>
                    <th>价格</th>
                    <th>vip价格</th>
                    <th>数量</th>
                    <th>图片</th>
                    <th>是否上架</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  <?php if(is_array($goodsinfo)): foreach($goodsinfo as $k=>$v): ?><tr>
                    <td class=""><input type="checkbox" name=""></td>
                    <td><?php echo ($v["goods_id"]); ?></td>
                    <td><?php echo ($v["goods_name"]); ?></td>
                    <td><?php echo ($v["goods_price"]); ?></td>
                    <td><?php echo ($v["goods_vip_price"]); ?></td>
                    <td><?php echo ($v["goods_num"]); ?></td>
                    <td><img src="<?php echo (ltrim($v["goods_small_pic"],'.')); ?>" width="70" height="50" /></td>
                    <td class='del'><?php echo ($v["goods_isdel"]); ?></td>
                    <td>
                      <a href="<?php echo U('goodsphoto',array('goods_id'=>$v['goods_id']));?>">相册管理</a>
                      <?php if($v["goods_isdel"] == '上架' ): ?><a href="javascript:;" class='isdel' data="<?php echo ($v["goods_id"]); ?>">下架</a>
                      <?php else: ?>
                      <a href="javascript:;" class='isdel' data="<?php echo ($v["goods_id"]); ?>">上架</a><?php endif; ?>
                      <a href="<?php echo U('goodsupd',array('goods_id'=>$v['goods_id']));?>">修改</a>
                      <a href="javascript:;" data="<?php echo ($v["goods_id"]); ?>" class="realdel">删除</a>
                    </td>
                  </tr><?php endforeach; endif; ?>
                </tbody>
              </table>
            </div>
            <div class="page">123</div>
          </div>
        </div>
      </div>
      <script src="/Public/Admin/public/js/jquery-3.1.1.js"></script>
      <!-- Include all compiled plugins (below), or include individual files as needed -->
      <script src="/Public/Admin/bootstrap/js/bootstrap.min.js"></script>
      <script type="text/javascript">
      //alert($)
      //复选框全部选中
      $(function(){
        $("#all").click(function(){
          if($(this).prop('checked')){
            $('#datalist :checkbox').prop('checked',true);
          }else{
            $('#datalist :checkbox').prop('checked',false);
          }
        });
        $('.isdel').click(function(){
          var _this = $(this);
          var id = $(this).attr('data');
          //alert(id);
          var data ={
              goods_id:id,
              _ : Math.random()
          };
          $.post("<?php echo U('goodsdel');?>",data,function(msg){
              //alert(msg);
              if(msg=='error'){
                alert('操作失败');
              }else if(msg==1){
                _this.html('下架');
                _this.parent().parent().find('.del').html('上架');
              }else{
                _this.html('上架');
                _this.parent().parent().find('.del').html('下架');
              }
          });
        });
        $('.realdel').click(function(){
          if(confirm('您是否删除')){
            var _this = $(this);
            var id = $(this).attr('data');
            var data ={
                goods_id:id,
                _ : Math.random()
            };
            $.post("<?php echo U('goodsrealdel');?>",data,function(msg){
              if(msg=='error'){
                alert('删除失败');
              }else{
                _this.parent().parent().remove();
              }
            });
          }
        });
      })
      </script>
  </body>
</html>